import 'package:fluttertest/models/route_model.dart';
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class TaskModel {
  final String waybillNumber;
  final String lineCode;  // 车牌号
  final String lineName;  // 查询人
  final String loadingNumber;      // 单据来源
  final String driverNumber;    // 装车时间
  final String driverName;      // 状态.
  final String followerName;      // 状态.
  final String followerNumber;      // 状态.
  final String carCode;      // 状态.
  final String plotformNumber;      // 状态.
  final String plotformCode;      // 状态.
  final int status;      // 状态.
  final int storeCount;      // 状态.
  final String setOutTime;      // 状态.
  final String backTime;      // 状态.
  final int duration;      // 状态.
  final String createTime;      // 状态.
  final String type;      // 状态.
  final String creater;      // 状态.
   int emptyTrunBox;      // 状态.
   int returnBox;      // 状态.
   int returnTurnoverBox;      // 状态.
   int numberOfItemsRedeemed;      // 状态.
   int yijianStatus;      // 状态.
   int signStatus;      // 状态.
   int skipNext;      // 状态.
  final int centerCode;      // 状态.
   int finishWatch;      // 状态.
   String finishWatchOwn;      // 状态.
   int realEmptyTrunBox;      // 状态.
   int fangsunWriteStatus;      // 状态.
  List<Sequence>? sequences;
  String mergeState;



  TaskModel({
    required this.waybillNumber,
    required this.lineCode,
    required this.lineName,
    required this.loadingNumber,
    required this.driverNumber,
    required this.driverName,
    required this.followerName,
    required this.followerNumber,
    required this.carCode,
    required this.plotformNumber,
    required this.plotformCode,
    required this.status,
    required this.storeCount,
    required this.setOutTime,
    required this.backTime,
    required this.duration,
    required this.createTime,
    required this.type,
    required this.creater,
    required this.emptyTrunBox,
    required this.returnBox,
    required this.returnTurnoverBox,
    required this.numberOfItemsRedeemed,
    required this.yijianStatus,
    required this.signStatus,
    required this.skipNext,
    required this.centerCode,
    required this.finishWatch,
    required this.finishWatchOwn,
    required this.realEmptyTrunBox,
    required this.fangsunWriteStatus,
    required this.mergeState,
    this.sequences,
  });

  factory TaskModel.fromJson(Map<String, dynamic> json) {
    return TaskModel(
      waybillNumber: json['waybillNumber'] ?? 0,
      lineCode: json['lineCode'] ?? '',
      lineName: json['lineName'] ?? '',
      loadingNumber: json['loadingNumber'] ?? '',
      driverNumber: json['driverNumber'] ?? '',
      driverName: json['driverName'] ?? '',
      followerName: json['followerName'] ?? '',
      followerNumber: json['followerNumber'] ?? '',
      carCode: json['carCode'] ?? '',
      plotformNumber: json['plotformNumber'] ?? '',
      plotformCode: json['plotformCode'] ?? '',
      status: json['status'] ?? '',
      storeCount: json['storeCount'] ?? '',
      setOutTime: json['setOutTime'] ?? '',
      backTime: json['backTime'] ?? '',
      duration: json['duration'] ?? '',
      createTime: json['createTime'] ?? '',
      type: json['type'] ?? '',
      creater: json['creater'] ?? '',
      emptyTrunBox: json['emptyTrunBox'] ?? 0,
      returnBox: json['returnBox'] ?? '',
      returnTurnoverBox: json['returnTurnoverBox'] ?? '',
      numberOfItemsRedeemed: json['numberOfItemsRedeemed'] ?? '',
      yijianStatus: json['yijianStatus'] ?? '',
      signStatus: json['signStatus'] ?? '',
      skipNext: json['skipNext'] ?? '',
      centerCode: json['centerCode'] ?? '',
      finishWatch: json['finishWatch'] ?? '',
      finishWatchOwn: json['finishWatchOwn'] ?? '',
      realEmptyTrunBox: json['realEmptyTrunBox'] ?? '',
      fangsunWriteStatus: json['fangsunWriteStatus'] ?? '',
      mergeState: json['mergeState']??'',
      sequences: (json['sequences'] as List<dynamic>?)
          ?.map((step) => Sequence.fromJson(step))
          .toList() ?? [],
    );
  }
}